<%@ page import="java.text.DecimalFormat" %>
<html>
<body>
    <%
        // 定义商品信息
        double unitPrice = Double.parseDouble(request.getParameter("unitprice")); 
        int quantity = Integer.parseInt(request.getParameter("quantity"));
        
        DecimalFormat df = new DecimalFormat("#.##"); 
        
        // 计算总金额
        double totalAmount = unitPrice * quantity;
        String formattedTotalAmount = df.format(totalAmount);
    
        out.println("<p>未打折前总价：" + formattedTotalAmount + " 元</p>");
        
        if (totalAmount >= 500){
            totalAmount *= 0.8;   
            String formattedDiscountedAmount = df.format(totalAmount);       
            out.println("<p style='color:green;'>满500打八折后的价格：" + formattedDiscountedAmount +"元 </p>");
        }
    %>
</body>
</html>